package com.ibm.android.format;

public class BusinessData {
	private String rawText;
	private String productName;
	private String description;
	private String vendorName;
	private String email;
	private double paymentAmount;
	private String currency;
	private String idTransaction;

	public BusinessData(String rawText) {
		this.rawText = rawText;
		String[] fields = rawText.split(":-:");

		for (int i = 0; i < fields.length; i++) {
			String field = fields[i];
			if (field.startsWith("PRODUCT_NAME:")) {
				this.productName = field.replaceFirst("PRODUCT_NAME:", "");
			}
			else if (field.startsWith("PRODUCT_DESCRIPTION:")) {
				this.description = field.replaceFirst("PRODUCT_DESCRIPTION:", "");
			}
			else if (field.startsWith("VENDOR_NAME:")) {
				this.vendorName = field.replaceFirst("VENDOR_NAME:", "");
			}
			else if (field.startsWith("EMAIL:")) {
				this.email = field.replaceFirst("EMAIL:", "");
			/*
			} else if (field.startsWith("DATE:")) {
				try {
					SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
					Calendar cal = Calendar.getInstance();
					Date d = sdf.parse(field.replaceFirst("DATE:", ""));
					cal.setTime(d);
					this.sendPaymentOn = cal;

				} catch (ParseException e) {
					e.printStackTrace();
				}
			*/
			}
			else if(field.startsWith("AMOUNT:")) {
				this.paymentAmount = Double.parseDouble(field.replaceFirst("AMOUNT:", ""));
			}
			else if (field.startsWith("CURRENCY")) {
				this.currency = field.replaceFirst("CURRENCY:", "");
			}
			else if (field.startsWith("TRANSACTION")) {
				this.idTransaction = field.replaceFirst("TRANSACTION:", "");
			} else if (field.startsWith("AMOUNT:")) {
				this.paymentAmount = Double.parseDouble(field.replaceFirst(
						"AMOUNT:", ""));
			} else {

			}
		}
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public double getPaymentAmount() {
		return paymentAmount;
	}

	public void setPaymentAmount(double paymentAmount) {
		this.paymentAmount = paymentAmount;
	}

	public String getIdTransaction() {
		return idTransaction;
	}

	public void setIdTransaction(String idTransaction) {
		this.idTransaction = idTransaction;
	}
	
	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getVendorName() {
		return vendorName;
	}

	public void setVendorName(String vendorName) {
		this.vendorName = vendorName;
	}

	public String getCurrency() {
		return currency;
	}

	public void setCurrency(String currency) {
		this.currency = currency;
	}
	
	/*
	public Calendar getSendPaymentOn() {
		return sendPaymentOn;
	}
	
	public void setSendPaymentOn(Calendar sendPaymentOn) {
		this.sendPaymentOn = sendPaymentOn;
	}
	*/

	public String toString() {
		return 
				"PRODUCT_NAME: " + this.productName +
				" - PRODUCT_DESCRIPTION: " + this.description +
				" - VENDOR_NAME: " + this.vendorName +
				" - EMAIL: " + this.email +
				" - AMOUNT: " + this.paymentAmount +
				" - CURRENCY: " + this.currency +
				" - TRANSACTION: " + this.idTransaction;
		/*
		int day = this.sendPaymentOn.get(Calendar.DAY_OF_MONTH);
		int month = this.sendPaymentOn.get(Calendar.MONTH) + 1;
		int year = this.sendPaymentOn.get(Calendar.YEAR);
<<<<<<< .mine
		return this.paymentAmount + " - " + day + "/" + month + "/" + year + " - " + this.email;
		*/

	}

	public String rawText() {
		return rawText;
	}

}
